home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / nurbsToPolyPreset.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.9 KB  |  93 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Mar. 14, 1997
  22. //  Author:         laf
  23. //
  24. //  Description:
  25. //      The nurbsToPolyPreset() procedure tesselates each 
  26. //        selected object.
  27. //
  28.  
  29. global proc nurbsToPolyPreset( int $doHistory, int $format,
  30.                                int $type, int $count,
  31.                                float $chr, float $ft,
  32.                                float $mel, float $d,
  33.                                int $ut, int $un, int $vt, int $vn,
  34.                                int $uch, int $ucr, float $cht, int $es )
  35. {
  36.     // Get a list of surfaces to tesselate and execute the cmd on each.
  37.     //
  38.     global int $gSelectNurbsSurfacesBit;
  39.  
  40.     string $surfaces[] = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit`;
  41.  
  42.     if( size($surfaces) > 0 ) {
  43.         // Piece together the tesselate command
  44.         //
  45.         string $cmd;
  46.         $cmd = "nurbsToPoly -mnd 1 " + " -ch " + $doHistory + " -f " + $format +
  47.             " -pt " + $type + " -pc " + $count + " -chr " + $chr +
  48.             " -ft " + $ft + " -mel " + $mel + " -d " + $d +
  49.             " -ut " + $ut + " -un " + $un + " -vt " + $vt + " -vn " + $vn + 
  50.             " -uch " + $uch + " -ucr " + $ucr + " -cht " + $cht +
  51.             " -es " + $es ;
  52.  
  53.         // Add the flag that will properly map texture space on
  54.         // tesselated trimmed surfaces.
  55.         //
  56.         $cmd = $cmd + " -ntr ";
  57.         $cmd = $cmd + "0";
  58.  
  59.         // add use the existing surface shader flag.
  60.         //
  61.         $cmd = $cmd + " -uss " ;
  62.         $cmd = $cmd + "1" ;
  63.  
  64.         $cmd = $cmd + " %s";
  65.  
  66.         string $results[] = executeForEachObject( $surfaces, $cmd );
  67.         if( (size($results)) == 0 ) {
  68.             error("NURBS to Polygons: Failed on the selected objects.");
  69.         }
  70.         else {
  71.             // Select all the results with one select command.  Note that only
  72.             // resulting meshes are selected, not dependency nodes.
  73.             //
  74.             string $selectString;
  75.             $selectString = "select ";
  76.             int $i;
  77.  
  78.             int $numResults = size($results);
  79.             for( $i = 0; $i < $numResults; $i ++ ) {
  80.                 $selectString += $results[$i];
  81.                 $selectString += " ";
  82.             }
  83.             $selectString += ";";
  84.             select -cl;
  85.             eval($selectString);
  86.         }
  87.     }
  88.     else {
  89.         error( "NURBS to Polygons: No valid items selected." );
  90.     }
  91. }
  92.  
  93.